# -*- coding: utf-8 -*-
from flask import Flask
from flask_cors import CORS
from .settings import config
from flask_sqlalchemy import SQLAlchemy

# import logging
# import sqlalchemy
#
# # 设置整体日志级别为WARNING
# logging.basicConfig(level=logging.WARNING)
#
# # 禁用sqlalchemy的日志输出
# sqlalchemy.engine.echo = False
#
# # 关闭sqlalchemy的日志记录器
# logging.getLogger('sqlalchemy.engine.Engine').setLevel(logging.ERROR)
#
# log = logging.getLogger('werkzeug')
# log.disabled = True

app = Flask(__name__, static_folder='../static', static_url_path='')
app_config = config['development']
app.config['JSON_AS_ASCII'] = False
app.config.from_object(app_config)

db = SQLAlchemy(session_options={'autocommit': False})
db.init_app(app)

CORS(app, supports_credentials=True)

from .controller import question_bp, chatglm_bp

# 注册蓝图
app.register_blueprint(question_bp, url_prefix='/api')
app.register_blueprint(chatglm_bp, url_prefix='/api')
